﻿//$(document).ready(function () {
//    //LayerTreeWidget();
//    show3DLayers();
//    var userno = getQueryString("idtf");
//    var mode = getQueryString("mode");
//    var layerguid = getQueryString("guid");

//    switch (mode) {
//        case "view"://浏览地图服务
//            //initializeView();
//            if (layerguid) {
//                initializeLayer(layerguid);
//            }
//            break;
//        case "query"://查询地图服务
//            initializeQuery();
//            break;
//        case "examine"://审核地图服务
//            initializeExamine(layerguid);
//            break;
//        case "sourcedata":
//            var fileUploadIP = InitialParameter("/Config.json")["fileUploadOrigin"].value;
//            other_objectToGeometry({
//                type: "url",
//                modelName: "sourcedata_" + layerguid,
//                object: "http://" + fileUploadIP + "/sw/upload/entityDataExtent/" + layerguid
//            });
//        case "test":
            
//            break;
//        case "default":
//            //$.getJSON("http://localhost:6080/arcgis/rest/services/BBXSERVER/BBX/MapServer/layers?f=pjson", function (result) {
//            //    console.log(result);
//            //});
//            break;
//        default:
//            break;
//    }
//});

//初始化浏览界面
function initializeView() {

}
//初始化查询界面
function initializeQuery() {
    spatialQuery();
}
//初始化加载图层
function initializeLayer(layerguid) {
    var layerNode = $(".lastlevel[guid='" + layerguid + "']");
    layerNode.find(".checkbox").click();
    var positions = m_LoadLayerInfo[layerguid].POSITION.split(',');
    setTimeout(function () {
        flyTo3DViewByLayerInfo(null, null, positions);
    }, 5000);
}
//初始化检查服务
function initializeExamine(layerguid) {
    var layerInfo = getDataServerLayerInfo(layerguid);
    if (layerInfo.code == "200" && layerInfo.data.length > 0) {
        layerInfo = layerInfo.data[0];
    }
    else {
        alert(layerInfo.msg);
        return;
    }
    var layerHelpExamine = new LayerHelper(layerInfo);
    layerHelpExamine.addLayer();
    setTimeout(function () {
        flyTo3DViewByLayerInfo(layerInfo["GUID"], layerInfo);
    }, 1000);
}
//获取地图服务信息
function getDataServerLayerInfo(guid) {
    var thisResult = {};
    $.ajax({
        type: "post",
        async: false,
        url: "/BaseAshx/Map/DataServer.ashx",
        data: //发送到服务器的参数
            {
                stype: "getDataServerLayerInfo",
                guid: guid
            },
        datatype: "json",
        success: function (result) {
            thisResult = JSON.parse(result);
        },
        error: function (err) {
            if (err.status == 405)
                top.location.href = '/';
        }
    });
    return thisResult;
}